package kr.saeildadim.androidexam_saeildamil.chapter9;

import kr.saeildadim.androidexam_saeildamil.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.widget.TextView;

public class OptionMenu extends Activity {
	TextView tv;
	final int JJANG = 1;
	final int JJAM = 2;
	final int WOO = 3;
	final int MAN = 4;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		tv = new TextView(this);
		tv.setText("메뉴키를 누르시요");
		setContentView(tv);
	}
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		super.onCreateOptionsMenu(menu);
		
		MenuItem item = menu.add(0,JJANG,0, "짜장");
		item.setIcon(R.drawable.ic_launcher);
		
		menu.add(0,JJAM,0,"짬뽕").setIcon(R.drawable.ic_launcher);
		
		SubMenu etc = menu.addSubMenu("기타");
		etc.add(0,WOO,0,"우동");
		etc.add(0,MAN,0,"만두");
		
		return true;
	}
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()){
		case JJANG:
			tv.setText("짜장은 달콤해");
			return true;
		case JJAM:
			tv.setText("짬뽕은매워");
			return true;
		case WOO:
			tv.setText("우동은 시원해");
			return true;
		case MAN:
			tv.setText("만두는 공짜");
			return true;
		}
		return false;
	}
}
